# Copyright (c) 2015 by Michael Zahniser
#
# Endless Sky is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later version.
#
# Endless Sky is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.  See the GNU General Public License for more details.

mission "First Contact: Hai"
	landing
	source
		attributes "hai"
	on offer
		conversation
			`This planet is populated by an alien species that resemble giant, intelligent squirrels. However, the most surprising aspect of the spaceport is not the aliens, but the fact that human merchants and other civilians are walking among them and are clearly at home here. Would you like to find someone who can tell you what is going on here?`
			choice
				`	(Sure.)`
				`	(Not right now.)`
					defer
			
			`	You walk up to a human merchant who is busy haggling with one of the aliens. They interrupt their conversation when they see you approaching, and the human gestures for you to join them. "You look totally lost," he says. "First time down the rabbit hole?"`
			`	You nod. The alien reaches out a paw to shake hands with you. "Welcome to Hai space," it says. "We are people of peace, and you are free to visit us or even live among us. Our worlds provide enough bounty for all."`
			`	You glance quickly at the human merchant to see his expression, wondering if these aliens can indeed be so benign, but his expression is calm and untroubled. "It's true," he says, "look around you. These buildings have stood for thousands of years. Hai society is so advanced, they need almost no resources to maintain it."`
			choice
				`	"Why do you allow humans to settle here?"`
				`	"What do you ask for in return for letting humans settle here?"`
			
			`	"Humans are a young species," the Hai says, "full of energy, full of new ideas. And the Hai are old, and everything we do is what we have done before. When humans go on vacation, they travel to a world with perfect weather, sunny every day. When Hai go on vacation, we visit the stormiest world, to find unpredictability and change. Humans are so strange, that to speak with a human is like a small vacation." It smiles, and you catch a glimpse of its massive incisors. Based on your knowledge of xenobiology you would guess that the Hai are herbivores, but you can't be certain.`
			choice
				`	"So I'm allowed to travel throughout your territory if I want?"`
					goto travel
				`	"How come people back in human space don't know that you are here?"`
			
			`	The human merchant laughs. "Probably because most of us came here to escape from the chaos and fighting in human space. The last thing we want is for it to follow us here. Not that I'm saying you can't tell anyone about the wormhole, but if I were you I wouldn't go spreading the news too widely either. And take a look around Hai space before you leave; you'll find that we could learn a lot from them."`
			`	"So I can travel anywhere I want in your territory?" you ask the Hai.`
			
			label travel
			`	"Yes," it says, "but be careful. The north is the territory of some renegade Hai: bandits and pirates, living off what they steal from the rest of us. If you travel among them, you will not be safe."`
			`	You talk for a while longer, but do not gain much additional information except that several of their worlds are willing to sell Hai technology even to human beings. You thank them both for stopping to talk with you, and the Hai responds, "We are always glad to welcome new friends. May peace dwell in your heart until we meet again."`
				decline
	on decline
		log "Factions" "Hai" `The Hai are a species of giant, intelligent rodents, who live to the north of human space. They allow any humans who discover their territory to live alongside them, and to trade with them and purchase their technology.`

mission "Discovered Hai Space"
	landing
	invisible
	source
		government "Hai"
	on offer
		event "label hai space"
		fail

event "label hai space"
	galaxy "label hai"
		sprite "label/hai"



mission "First Contact: Unfettered"
	landing
	source
		attributes "unfettered"
	on offer
		conversation
			`The Hai here appear to be at war with the rest of their species. Do you want to approach one of them and ask why?`
			choice
				`(Sure.)`
				`(Not now, it's too risky.)`
					defer
			`	You catch the eye of one of the Hai dock workers and it walks over. "Ah," it says, "the monkey is curious. The monkey has never been face to face with a true Hai before?"`
			choice
				`	"No, I've encountered many of your brethren south of here."`
					goto brethren
				`	"What do you mean, 'true Hai'?"`
					goto true
				`	"Why are you at war with everyone else?"`
					goto everyone
			
			label brethren
			`	It hisses. "They are not true Hai. We are Hai. The unaltered. We were masters of a hundred worlds before human monkeys had learned the use of thumbs."`
				goto masters
			
			label true
			`	"It means that we are unaltered, Hai as Hai were first born to be. Hai the conquerors. We were masters of a hundred worlds before human monkeys had learned the use of thumbs."`
				goto masters
			
			label everyone
			`	"We fight to defend ourselves from extinction," it says.`
			`	"'Extinction?'" you ask. "Do you mean that you are not the same species as the other Hai?"`
			`	"Indeed," it says. "We are all that is left of the original Hai. Unaltered. The conquerors. We were masters of a hundred worlds before human monkeys had learned the use of thumbs."`
				goto masters
			
			label masters
			choice
				`	"Where was your territory? Why have I never heard of you before?"`
				`	"What do you mean, the Hai were altered?"`
	
			`	"This is our story," it says. "Once, many worlds beyond wormhole were ours. Once, hundred thousand years now gone. We needed more worlds. A species that does not expand becomes like brackish water, like stunted tree. But dragonfolk in the south had created hyperdrive, and human monkeys had begun banging rocks together in what the Drak said was very intelligent fashion. So we were forbidden from taking more worlds."`
			`	"'Dragonfolk?'" you ask. "I've never heard of them."`
			`	"Sheragi," it says, "they are extinct. Only their dumb ancestors survive, just as monkeys will outlast the thinking humans."`
			`	"How were you altered?" you ask.`
			`	It says, "We Hai took worlds that Drak said belonged to Sheragi, although Sheragi had not yet even discovered them. Drak retaliated. On all Hai worlds, Drak ships appeared in orbit. Sickness swept each planet: quick fever, strange feeling of frailness, like you are brittle bones with mouth full of dirt. Victims left alive, but all ambition gone, no desire but to die of comfortable old age."`
			choice
				`	"Did you try to resist the Drak?"`
					goto resist
				`	"How do you know this, if it happened a hundred thousand years ago?"`
					goto know
			
			label resist
			`	"Silly monkey," it says, "none can resist. They are strong. Their will prevails. And their will is for the galaxy to be a zoo, little remnants of each species all in separate cages. For now they let humans run free so humans will grow in knowledge, but soon they will fashion a cage for humans too."`
				goto help
			
			label know
			`	"All Hai know. The story is passed down. Others tell an altered version, where the way of peace was choice and not an inflicted wound, but some in each generation learn truth, and join us here."`
				goto help
			
			label help
			choice
				`	"That is a frightening story. Thank you for taking the time to speak with me."`
					decline
				`	"Is there anything I can do to help you?"`
			
			`	"If you are ever willing to sell us a jump drive," it says, "we will richly reward you. And if you discover the secret of how we can construct our own jump drives and escape from this prison, bring it to us and you will live as a god among us."`
			choice
				`	"I'm sorry, I don't know the secret of the jump drive. No human being does."`
				`	"If I ever have an extra jump drive to sell, I will bring it to you."`
					goto sell
			`	"Then leave us alone," it says, and it walks off.`
				decline
			
			label sell
			`	"Bring us a jump drive," it says, "and we will count you among our friends. Bring us more, and we may even consider you worthy of a share of the plunder, when we take back what is ours."`
				decline

	on decline
		log "Factions" "Unfettered Hai" `The "Unfettered" are a faction within the Hai species who are not as peaceful as the rest, and are normally not friendly toward humans. They claim that long ago the Drak altered the Hai to make them docile and peaceful, and that the Unfettered are descendants of those Hai who avoided undergoing that alteration. They are seeking jump drives so that they can escape the "prison" they are now stuck in: a few deteriorating worlds on the far northern edge of Hai space.`
		log "Factions" "Sheragi" `The Unfettered Hai say that a dragon-like species called the "Sheragi" who are long extinct used to live in human space, back when much of what is now human territory was occupied by the Hai.`



mission "Ask the Hai about the Unfettered"
	landing
	source
		attributes "hai"
	to offer
		has "First Contact: Unfettered: offered"
	on offer
		conversation
			`The Unfettered Hai told you that they are the "true Hai," and seem to think that the other Hai are oppressing them. Would you like to look for someone here who can tell you the other side of the story?`
			choice
				`	(Yes.)`
				`	(No.)`
					decline
			`	You find an elderly-looking Hai who is sitting on a bench watching the starships land and take off. As you approach, he says, "Hello human."`
			choice
				`	"Hello. I've met some of the Unfettered Hai. What can you tell me about them?"`
				`	"Hello. Can you tell me why you are at war with the other Hai who live to the north?"`
					goto war
			`	He says, "Ah, our wayward sisters and brothers to the north. You have surely seen what our society is like: safe, stable, predictable, deliberate. It suits most of us well. But there are those..."`
				goto raids
			label war
			`	He says, "I would not call it war. We launch no raids on them. We only defend when they attack. And, we supply them with food and other things needful for life. They are not our enemies, they are just those who do not fit in. You have surely seen what our society is like: safe, stable, predictable, deliberate. It suits most of us well. But there are those..."`
			label raids
			`	He pauses. "No, I am telling this unfairly. I will start again. Hundreds of years ago, when I was young, our territory was raided by aliens from the east, who came in massive warships and plundered our worlds. In those days there were some Hai who were brave enough to risk their lives to defend us. The raids lasted for decades, then abruptly stopped.`
			`	"Most of those who had fought the invaders were glad to return to ordinary life, but there were some for whom life now seemed bland and meaningless without the excitement and chaos of war. They started colonies in the systems to the north, and fought amongst themselves, and mismanaged the land, and grew in numbers. And now their worlds cannot feed them all, and they invade us and tell stories to put blame on us for their failures."`
			choice
				`	"Shouldn't they be treated with gratitude for defending you against the raiders?"`
				`	"They said the Drak altered the Hai to make them less aggressive. Is that true?"`
					goto drak
				`	"That's all I wanted to know. Thanks."`
					decline
			`	"They were, and still should be. There will always be times when our society needs them. Only at this time, the need is not so great. There is no new frontier for them to explore, no worthy challenges for them to face. And we fear what would happen if they ventured south and gained access to the wormhole, so we must force them to stay where they are."`
			choice
				`	"They said the Drak altered the Hai to make them less aggressive. Is that true?"`
				`	"That's all I wanted to know. Thanks."`
					decline
			label drak
			`	"No," he says, "it is a story they invented, that the Hai were destined to be masters of the galaxy but the Drak and the Quarg prevented us. The story is not true. Our civilization beyond the wormhole was brought down by infighting and unwise governance. Amid the wreckage we studied and thought and argued and came to believe that we could rule a small territory with stability and peace, or hold more worlds but with constant turmoil. We chose stability, and relinquished those worlds."`
			choice
				`	"So you don't think the Drak are keeping us all in cages?"`
				`	"That's all I wanted to know. Thanks."`
					decline
			`	He thinks about the question for a while, then says, "Sometimes we make a fire for cooking food. The fire consumes much wood, and the flames are tall, too wild and hot to cook food well. Then the wood becomes coals that burn slowly with no flames or smoke, and when you gather them they are good for roasting meat or even baking bread. Perhaps each species must consume many worlds and many resources before learning to burn slowly, and the wisdom of the Drak is to allow them to do so. But when they find balance, as we did, they no longer need so much space."`
			`	You thank him for taking time to speak with you, and say goodbye.`
				decline



mission "Unfettered Jump Drive 1"
	name "More Jump Drives"
	minor
	description "The Unfettered Hai have promised you rich rewards if you bring them more Jump Drives."
	landing
	to offer
		has "First Contact: Unfettered: offered"
		not "Wanderers: Jump Drive Source: active"
	to fail
		has "event: wanderers: unfettered invasion starts"
	to complete
		has "Unfettered Jump Drive 2: offered"
	source
		attributes "unfettered"
	on offer
		conversation
			`The Unfettered have clearly noticed that you have a jump drive installed; a large crowd of them has gathered around your ship. Do you want to talk with them, and perhaps arrange a sale of your jump drive?`
			choice
				`	(No.)`
					defer
				`	(Yes.)`
			`	As soon as you approach the crowd, one of them steps forward and says, "One million credits, and the friendship of the true Hai people. This is our offer, for the jump drive."`
			choice
				`	"Sure, I will accept that deal."`
					goto end
				`	"Can you offer me more than that?"`
					goto more
				`	"How will my ship leave here without my jump drive?"`
			
			`	"We will give you a hyperdrive in its place," it says, "and you will be counted as our friend, so you will not need to leave here quickly, or under threat of violence." You can't help but wonder if they will try to take your ship by force if you do not agree to the deal.`
			choice
				`	"Okay, I accept your generous offer."`
					goto end
				`	"Sorry, but if I give you this jump drive, I will lose my ability to capture more of them. Be patient, and I will bring you several of them when I am able."`
					goto refuse
			
			label refuse
			`	It ponders this for a while, and says, "Very well. Our offer stands, whenever you choose to return." They allow you to return to your ship peacefully.`
				defer
			
			label more
			`	"Do not underestimate the value of our friendship," it says. "Soon we will become powerful once more, with many fruitful worlds under our control, and when that day comes you will benefit greatly from being our ally."`
			choice
				`	"Okay, as long as you give me a hyperdrive to take its place, I'll give you my jump drive."`
					goto end
				`	"Sorry, but if I give you this jump drive, I will lose my ability to capture more of them. Be patient, and I will bring you several of them when I am able."`
					goto refuse
			
			label end
			`	The Unfettered engineers quickly and carefully remove your jump drive and replace it with an ordinary hyperdrive. You sincerely hope that you are not making a mistake by giving them this new technology. "Remember," one of them says as it hands you your payment, "when you acquire more jump drives, return here with them and we will give you further rewards. Until then, may fortune favor you, human friend."`
				accept
	
	on accept
		outfit "Jump Drive" -1
		outfit "Hyperdrive" 1
		payment 1000000
		"reputation: Hai (Unfettered)" >?= 10



mission "Unfettered Jump Drive 2"
	name "More Jump Drives"
	minor
	description "The Unfettered Hai have promised you rich rewards, and more information about their plans, if you bring them more Jump Drives."
	landing
	to offer
		has "Unfettered Jump Drive 1: offered"
		not "Wanderers: Jump Drive Source: active"
	to fail
		has "event: wanderers: unfettered invasion starts"
	to complete
		has "Unfettered Jump Drive 3: offered"
	source
		attributes "unfettered"
	on offer
		conversation
			`As before, when you land on this Unfettered world with a jump drive, a large crowd gathers around your ship. Clearly they are hoping that once again you will arrange a sale. Do you want to bargain with them?`
			choice
				`	(No.)`
					defer
				`	(Yes.)`
			`	When you approach the crowd, one of them says, "Greetings, human friend. We have made you known to all our brothers and sisters as one of the few creatures who have chosen to help the true Hai to gain their freedom. If you give us another jump drive, we will pay you another million credits, and make you one of our emissaries to collect the payments with which our frail brothers seek to buy peace. Will you accept this exchange?"`
			choice
				`	"Sorry, I need this jump drive right now, but I will come back later and sell it to you."`
					defer
				`	"Yes, I will sell you my jump drive."`
			`	Once again, they swap your jump drive for a hyperdrive, and pay you far more than you could sell a jump drive for anywhere else. "We will tell the other true Hai to offer you jobs in our job boards," they tell you, "and remember that we need still more jump drives."`
			choice
				`	"Then I will find more, and bring them to you."`
					accept
				`	"Can you tell me what you are using them for?"`
			`	"Not yet. If you further prove your friendship, perhaps we will." You assure them that you will continue to do your best to assist them.`
				accept
	
	on accept
		outfit "Jump Drive" -1
		outfit "Hyperdrive" 1
		payment 1000000
		"reputation: Hai (Unfettered)" >?= 20
		fail "Unfettered Jump Drive 1"



mission "Unfettered Jump Drive 3"
	name "More Jump Drives"
	minor
	description "If you find more Jump Drives, you can sell them to the Unfettered Hai for considerably more money than they are worth elsewhere."
	landing
	to offer
		has "Unfettered Jump Drive 2: offered"
		not "Wanderers: Jump Drive Source: active"
	to fail
		has "event: wanderers: unfettered invasion starts"
	to complete
		has "Unfettered Jump Drive 4: offered"
	source
		attributes "unfettered"
	on offer
		conversation
			`You have another jump drive, and the Unfettered will certainly be willing to pay you well for it. They also hinted that they might be willing to give you more information about what they plan to use the jump drives for. Do you want to sell them another drive?`
			choice
				`	(No.)`
					defer
				`	(Yes.)`
			`	You meet up with some local Unfettered leaders, and they again pay you a million credits and arrange for your jump drive to be swapped out of your ship. "If you bring more, we will continue to pay you," they say.`
			choice
				`	"Can you tell me what you are using the jump drives for?"`
				`	"Thank you, I will certainly bring more of them when I am able."`
					accept
			`	After a brief and hushed discussion in their own language, one of the leaders says, "You have proven your worth, so we will share our secret. The Hai once owned many worlds on the galactic fringe, a territory we can only visit using the jump drive. Those worlds are fruitful and nearly uninhabited. We will reclaim them as our own, and there will be food there to feed the Unfettered for many thousands of years to come."`
			branch know
				has "First Contact: Wanderer: offered"
			choice
				`	"Is there any other way I can help you to reclaim those worlds?"`
					goto help
				`	"'Nearly uninhabited?' You mean another species inhabits some of those worlds now?"`
					goto wanderers
			
			label know
			`	You suspect that they are talking about the territory that is now inhabited by the Wanderers.`
			choice
				`	"Are you at war with the Wanderers? Can I help you to reclaim your territory?"`
					goto help
				`	"What are you going to do to the species that owns those worlds right now?"`
					goto wanderers
			
			label help
			`	"Your help may indeed be beneficial to us," says the leader. "I will tell the others to contact you if they have any particular missions you can undertake."`
			choice
				`	"I look forward to hearing from them."`
					accept
				`	"What do you plan to do to the species that inhabits those worlds now?"`
			
			label wanderers
			`	"Those worlds are now held by a species of scavengers, who feast on the ruin of proud civilizations. Our scouts tell us that these carrion-feeders have wiped away nearly every Hai artifact, melting down our cities to make metal for their ships and factories, and hiding the scars of our wars beneath newly planted forests. They are an old and strong species, but few in number, and those worlds are ours by right."`
			`	You try to press them for more information, but they tell you nothing useful, aside from promising you that they will seek out your help when it is time to reclaim their territory.`
				accept
	
	on accept
		outfit "Jump Drive" -1
		outfit "Hyperdrive" 1
		payment 1000000
		"reputation: Hai (Unfettered)" >?= 30
		fail "Unfettered Jump Drive 2"



mission "Unfettered Jump Drive 4"
	repeat
	minor
	to offer
		has "Unfettered Jump Drive 3: offered"
		not "Wanderers: Jump Drive Source: active"
	to fail
		has "event: wanderers: unfettered invasion starts"
	to complete
		never
	source
		attributes "unfettered"
	on offer
		conversation
			`Would you like to sell another jump drive to the Unfettered?`
			choice
				`	(No.)`
					defer
				`	(Yes.)`
			`	As usual, they are more than willing to pay you a million credits for your jump drive, but you do not gain any additional information by talking with them.`
				accept
	
	on accept
		outfit "Jump Drive" -1
		outfit "Hyperdrive" 1
		payment 1000000
		"reputation: Hai (Unfettered)" >?= 40
		fail "Unfettered Jump Drive 3"
		fail "Unfettered Jump Drive 4"



mission "Unfettered returning home"
	description "This Hai has asked you to smuggle him out of Unfettered space and bring him to <destination>."
	minor
	source
		attributes "unfettered"
	destination "Hai-home"
	clearance
	passengers 1
	to offer
		has "Unfettered Tribute 3: done"
		random < 40
	on offer
		conversation
			`During the night, you hear a gentle scratching sound on your ship's main hatch. Do you investigate?`
			choice
				`	(Yes.)`
				`	(No.)`
					defer
			`	You grab a flashlight and open the hatch, and find a juvenile Hai there, with a large satchel slung over his shoulder. "You are the <first> <last>, yes?" he says. You nod. He says, "Is it true what is written here?"`
			`	In his hands he is holding a piece of foil paper. You recognize it as the wrapper from one of the food rations that you have been transporting to the Unfettered, the "tribute" that they demand from the peaceful Hai. But having never unwrapped one of the rations, you had not realized that there is writing on the inside, a few words in the angular alphabet of the Hai. The Unfettered youth sees your look of confusion, and translates the message. "It says, 'Hai-home is your home too. Rejoin your people.'"`
			choice
				`	"I think it is true. The Hai who gave this tribute said they hoped the Unfettered would turn from violence and be reconciled with them."`
					goto true
				`	"I'm sorry, but I don't think they will ever let you live among them, if it is your nature to be prone to violence."`
			`	You have little experience reading Hai emotion, but the youth seems crestfallen. "You are certain?" he asks.`
			choice
				`	"I am certain. I can do nothing for you."`
					goto refuse
				`	"Perhaps you can come with me and find out, but don't get your hopes up."`
					goto end
			label true
			`	"Will you take me to Hai-home?" he asks. "You are able to be outside Unfettered places. Can I go with you?"`
			choice
				`	"Yes, I will take you there."`
					goto end
				`	"Sorry, I can't risk angering the Unfettered by carrying a defector."`
			label refuse
			`	Disappointed, the youth leaves. You hope you made the right choice.`
				decline
			label end
			`	You show the youth to one of your bunk rooms, and tell him to stay hidden there until you reach Hai-home.`
				accept
	
	on visit
		dialog `You look for the young Hai, but realize that he took a ride on one of your escorts! Better depart and wait for your escorts to arrive in this star system.`
	on complete
		payment 100000
		dialog
			`You need not have worried about the reception the Unfettered youth would receive here on Hai-home. Scarcely minutes after you hesitantly contact the Hai government, a happy crowd has gathered around your ship. When he steps out of the hatchway, he looks stunned at being welcomed so warmly. One of the Hai governors thanks you for transporting him, and pays you <payment>.`
		"reputation: Hai" += 10



mission "Returning Home"
	description "Bring Elliot home to his family on <destination>. Elliot ran away from his family as a teenager and hasn't seen them in almost six years."
	minor
	source
		government "Hai"
	destination
		attributes "dirt belt"
		attributes "farming"
	passengers 1
	to offer
		random < 40
	on offer
		conversation
			`You are stopped by a human in the <origin> marketplace. He takes off his hat and asks, "You're from the outside, aren't you?"`
			choice
				`	"Yes, I am."`
					goto outsider
				`	"What do you mean 'the outside?'"`
			
			`	"Outside of Hai space. Your ship looks newer than most of the ships that humans fly around here."`
			choice
				`	"Oh, yes. I do come from outside."`
			
			label outsider
			`	"Good. My name is Elliot." You introduce yourself to Elliot and shake hands.`
			`	"Can you take me to <destination>?" Elliot asks.`
			`	"That's all the way in the Dirt Belt," you say. "Why do you want to go that far?"`
			`	Elliot looks down at the ground for a second and takes a deep breath while gripping his hat in his hands. "You see, I haven't lived here all my life. I was born on <planet> to a poor farming family. Most of my days were spent working on the farm, which I hated with a passion. One day I just got fed up with things and I ran away.`
			`	"I ran away from home to the spaceport city and snuck my way into the cargo hold of a freighter. The captain didn't open the cargo hold for three weeks while I stayed in it. Lucky for me the freighter was transporting food, so I had plenty to eat.`
			`	"When the cargo hold doors finally opened, I ran out as fast as I could, only to run back in at the sight of a group of Hai. I had no idea where I was at the time, but I've been living here ever since. That was when I was thirteen, nearly five years ago now."`
			`	Elliot looks down at the ground again and wipes a tear from the corner of his eye.`
			choice
				`	"Alright, I'll take you to <planet>."`
					goto accept
				`	"And you finally want to go back home?"`
				`	"Sorry, but I'm not able to take you that far."`
					goto decline
			
			`	"Yes. I've thought a lot about it lately. I want to see my family again."`
			choice
				`	"Alright, I'll take you to <planet>."`
					goto accept
				`	"Sorry, but I'm not able to take you that far."`
			
			label decline
			`	"I understand," Elliot says. "I'll just try and find someone else to help me. Goodbye, <first>."`
				decline
			
			label accept
			`	You lead Elliot to your ship and show him to a bunk room. After leaving Elliot there, you wonder if his family is still even on <planet> anymore.`
				accept
			
	on visit
		dialog `You look for Elliot, but realize that he took a ride on one of your escorts! Better depart and wait for your escorts to arrive in this star system.`
	on complete
		payment 45000
		conversation
			`Elliot thanks you for bringing him to <planet> and hands you <payment>. He flags down a taxi just outside the spaceport, but before entering the taxi he turns back to you.`
			`	"Do you want to come with me? I'd love for you to meet my family. They'll want to meet you when I tell them how I got back."`
			choice
				`	"Sorry, I have other places to be. Good luck."`
				`	"Sure. I've come with you this far."`
					goto sure
			
			`	"I understand. Thanks again, <first>. I'll always owe you."`
			`	Elliot gets into the taxi, which drives off toward the seemingly endless farmlands outside of the spaceport city.`
				decline
			
			label sure
			`	The view for nearly the entire three hour drive is of hills and farmland with the occasional building or wild animal. Elliot shakes as the taxi approaches the house from the driveway. "I'm wondering if they still even live here," he says nervously.`
			`	No one comes out of the house when the taxi stops. You walk up to the front door with Elliot and a middle-aged woman answers the door with a mug of coffee and a bewildered look on her face.`
			`	"Can I help you?" the woman asks.`
			`	Elliot looks over at you with a big smile on his face. "Yes you can, mom," he says to her. The woman's face lights up with joy and she begins jumping up and down, spilling coffee from her mug.`
			`	"Oh Elliot, I can't believe it!" Elliot's mom puts down her mug and leaps out the door to hug him. "Jackson! Sarah! Abby! Sean! Victor! Elliot is here!" Elliot's entire family comes out from the house and greets him, asking dozens of questions about where and how he's been and why he left.`
			`	Elliot introduces you to his family, who thank you for bringing Elliot home. Victor, who was only seven years old when Elliot left and is now twelve, asks you question after question about being a pilot, sometimes asking new questions before you can even answer the old one.`
			`	"Are you going back to the spaceport, <first>?" the taxi driver yells from the driveway. "I need to get back to the city as soon as I can."`
			`	You say goodbye to Elliot and to his family. "Thanks again, <first>," Elliot says. "I'll always owe you."`



mission "Unwanted Cargo Trigger"
	invisible
	landing
	source
		government "Hai"
	to offer
		random < 10
		"cargo space" > 0
	on offer
		event "hai in cargo" 14
		fail

event "hai in cargo"

mission "Unwanted Cargo"
	landing
	description "Bring a Hai child who hid in your cargo hold back to <destination>."
	source
		government "Republic" "Free Worlds" "Syndicate" "Neutral"
	destination "Allhome"
	to offer
		has "event: hai in cargo"
	on offer
		conversation
			`The "Check Cargo" light for your ship begins blinking when you land, meaning that a cargo crate may have come loose in flight. You shut off the ship's engines and walk to the cargo hold.`
			`	You check every cargo crate in the hold, but can't find anything wrong. Right as you decide to leave, one of the smaller crates begins rocking back and forth.`
			branch translator
				has "language: Wanderer"
				
			`	You hear a voice come from the crate, but it is not a language you understand. The voice continues to speak, and you recognize it as the Hai language.`
			choice
				`	(Open the crate.)`
			`	You open the crate and are met face to face with a Hai child. You aren't sure how old it is, but it looks to be about the size of a one-year-old human child. It tries to communicate with you, but begins to cry when it sees the confused look on your face.`
			choice
				`	"Don't cry, little guy."`
					goto cry
				`	(Pick up the Hai.)`
				
			`	The child waves its hands around when you try to pick it up, making it impossible to grab on to. After waiting for a few minutes, the child finally calms down, eventually going to sleep in the crate.`
				goto end
			
			label cry
			`	The child begins to cry even louder than before. After waiting for a few minutes, the child finally calms down, eventually going to sleep in the crate.`
				goto end
			
			label translator
			`	You hear a voice come from the crate, and surprisingly your Hai translator begins speaking. "Let me out! I want to go home!"`
			choice
				`	(Open the crate.)`
			`	You open the crate and are met eye to eye with a Hai child. You aren't sure how old it is, but it looks to be about the size of a one-year-old human child. "I want my mommy!" it says as its eyes begin to tear up.`
			choice
				`	"Where's your mommy?"`
				`	"Don't cry, little guy."`
			`	The child looks surprised when your translation device speaks to it in Hai. "Take me home!" it yells back at you. You attempt to find out where the child's home is, but it continues to cry for its mother without giving any important information.`
			
			label end
			`	This child must have somehow gotten into your cargo hold while you were in Hai space. Leaving a Hai child on a human world would be an extremely bad idea. Perhaps someone on <destination> will be able to bring the child back to its family.`
				accept
			
	on complete
		payment 50000
		dialog `You contact the spaceport authorities of <planet> and ask them if they are looking for a lost Hai child. It turns out that the family was so worried that they put up a <payment> reward for finding their son. A Hai spaceport worker takes the child from your ship and thanks you for finding him for the family.`



mission "Expanding Business [1]"
	name "An Interesting Proposition"
	description "Travel with businessman David Turner to <destination> where a convoy of freighters are awaiting escort."
	minor
	source "Greenwater"
	destination "Allhome"
	to offer
		has "First Contact: Hai: offered"
		has "main plot completed"
	on offer
		conversation
			`Walking through the <origin> spaceport, you notice that almost half of the people you see are humans, unlike other Hai worlds where the Hai outnumber humans by a sizable degree. A human dressed in a business suit shouts your name from across the street and approaches you.`
			`	"Captain <last>, one of the many heroes of humanity! I noticed you right away when I laid my eyes upon you. I'd like to personally thank you for what you've done."`
			choice
				`	"Glad to get some recognition for all the hard work I've done."`
					goto boast
				`	"Don't mention it. I just did what I could to help."`
					goto downplay
				`	"Can I help you, sir?"`
			
			`	"I'm the one who should be using formal titles to address you, so please, Captain, don't call me sir.`
				goto proposition
			
			label boast
			`	"A personality as big as yourself should be receiving praise and recognition wherever you go! People must really have no respect these days.`
				goto proposition
			
			label downplay
			`	"No need to downplay yourself, Captain! You've done God's work in saving humanity from that alien scourge.`
			
			label proposition
			`	"The name's David Joseph Turner, venture capitalist, entrepreneur, and famous Paradise Worlds businessman." Turner grabs a business card from his pocket and hands it to you. The card contains his contact information, an address on Martini, and makes sure to boast in golden letters his net worth of more than three billion credits.`
			`	"You may not have heard of me, but I've sure as hell heard of you, and I'd like to make a proposition to you." Turner turns around and waves his arm across the crowd of people in the spaceport. "You see all the humans here? About one out of every four of these people only arrived here after war broke out through the wormhole. Captains who knew of the Hai came flocking here in droves after the Navy entered Kornephoros, hoping to avoid any troubles that the war would bring. Some captains returned after the war ended, but most stayed, and I see a massive market opportunity in that."`
			branch rich
				"net worth" >= 4000000000
			
			choice
				`	"What kind of market opportunity?"`
					goto opportunity
				`	"Sorry, but I don't have the time to talk about this."`
					goto walk
			
			label rich
			choice
				`	"What kind of market opportunity?"`
					goto opportunity
				`	"You're only worth three billion credits? Why shouldn't I pursue your opportunity on my own?"`
				`	"Sorry, but I don't have the time to talk about this."`
					goto walk
			
			`	"Of course you're worth more than me, Captain <last>, but you are no business owner. I have the connections and skills, but a name like yours will always help.`
				goto opportunity
			
			label walk
			`	You try to walk away, but Turner stops you by grabbing your arm and continues to talk.`
			
			label opportunity
			`	"Allow me to explain. The journey to the Hai can be a dangerous one, and you know that. I heard many stories during the war of merchants trying to reach the Hai, but thanks to the Navy being distracted, those merchants fell victim to pirates patrolling the systems of the Far North. Now that many merchants are here, they're trapped. They expended most of if not all of their ammunition trying to get here, and now they have none to defend them on their way back. Human ammunition has become a scarce commodity among human captains in this region of space, leaving open a market that's just waiting to be cornered.`
			`	"I'd like you, Captain <last>, hero of humanity, to help me set up an outfitter here on <origin>, an outfitter that would supply these desperate merchants with relief by supplying them with the ammunition they need, along with outfits they might want to buy for their old ships. I've already received approval from the Hai government for the construction of an outfitter, and with a name like yours backing up this business, the profits are sure to be phenomenal, profits that you would be sharing in by being a founding member of this outfitter."`
			choice
				`	"This sounds like a good idea to me. What do you need me to do?"`
					goto interested
				`	"Sorry, but I'm not interested in your proposition."`
			
			`	"Nonsense, Captain! All you'd need to do is help escort a few freighters from <planet> to Follower and back to here, and for so simple a job you could be receiving enough money to not work another day in your life, or perhaps even support a massive fleet."`
			choice
				`	"Again, I'm not interested. Goodbye."`
				`	"Alright, you have my attention."`
					goto interested
			
			`	"Well, I tried, Captain," Turner says with a smirk. "I'll just have to travel back to the Paradise Worlds and make my money in other areas of business, then." He hands you another business card and winks. "Goodbye, Captain <last>. You should know where to find me if you need me. Perhaps we can pursue this venture together in the future."`
				decline
			
			label interested
			`	"Excellent, Captain! I'll be making myself comfy on my own ship. A convoy of freighters is waiting for us on <destination>. From there, we're off to Follower to pick up supplies."`
				accept
				
	npc accompany save
		personality escort
		government "Merchant"
		ship "Star Queen (Hai)" "Chryso Vasilia"
	
	on visit
		dialog `You've reached <planet>, but you've left Turner behind. Wait for Turner's ship to arrive before landing.`
	
	on complete
		dialog `The freighters are ready to launch by the time you get to <planet>. "Now we just need to escort these freighters to Follower in the Alphard system and back in one piece," Turner exclaims, hopping back on to his Star Queen.`

mission "Expanding Business [2]"
	landing
	name "An Interesting Proposition"
	description "Escort the freighters to <destination> where they will pick up supplies for the Greenwater outfitter."
	destination "Follower"
	to offer
		has "Expanding Business [1]: done"
	
	npc accompany save
		personality escort
		government "Merchant"
		ship "Star Queen (Hai)" "Chryso Vasilia"
	npc accompany save
		personality escort
		government "Merchant"
		fleet
			names "civilian"
			variant
				"Bulk Freighter (Hai)" 3
	
	npc
		personality staying
		government "Pirate"
		system "Ultima Thule"
		fleet "Small Northern Pirates"
	npc
		personality staying
		government "Pirate"
		system "Rajak"
		fleet "Large Northern Pirates"
	npc
		personality staying
		government "Pirate"
		system destination
		fleet "Large Northern Pirates"
	
	on visit
		dialog `You've reached <planet>, but you've left one of the ships you're supposed to be escorting behind. Wait for Turner's ship and all the Bulk Freighters to arrive before landing.`

mission "Expanding Business [3]"
	landing
	name "An Interesting Proposition"
	description "Escort Turner's ship to <destination> so that he can speak with an old friend."
	destination "Rust"
	to offer
		has "Expanding Business [2]: done"
	on offer
		conversation
			`Turner jumps off of his Star Queen before the boarding ramp fully reaches the ground, clearly eager to get moving with this project.`
			`	Turner swears under his breath when he walks up to you. "Low life pirates giving us trouble on the way here. That's the kind of trouble I'm talking about that an outfitter in Hai space would help with. There's no telling what would have happened had my Bulk Freighters not had their missiles. Or if you were not there to protect them, of course."`
			`	Turner has a talk with the spaceport authorities, and within a short amount of time the necessary cargo is loaded on to the freighters. When the freighters are fully loaded, they take off without even giving you time to get to your ship.`
			`	"They can get back to Greenwater on their own," Turner says from behind you as you watch the freighters fly off. "I told them to leave as soon as they could. As for you and me, I need escort to <destination>. I received a message from an old friend there who would like to have a chat with me."`
				accept
				
	npc accompany save
		personality escort
		government "Merchant"
		ship "Star Queen (Hai)" "Chryso Vasilia"
		
	on visit
		dialog `You've reached <planet>, but you've left Turner behind. Wait for Turner's ship to arrive before landing.`

mission "Expanding Business [4]"
	landing
	name "An Interesting Proposition"
	description "Escort Turner back to <destination> to oversee the construction of the outfitter."
	destination "Greenwater"
	to offer
		has "Expanding Business [3]: done"
	on offer
		conversation
			`Turner lands his ship outside of the Kraz Cybernetics building. "Wait here while I have a talk with my friend, Edward. This should only take a few minutes."`
			`	A few hours later, Turner returns carrying a black suitcase. "Sorry, that took longer than I expected. Now, let's get back to <destination>."`
				accept
	
	npc accompany save
		personality escort
		government "Merchant"
		ship "Star Queen (Hai)" "Chryso Vasilia"
	
	on visit
		dialog `You've reached <planet>, but you've left Turner behind. Wait for Turner's ship to arrive before landing.`
	
	on complete
		event "outfitter on greenwater" 95
		conversation
			`By the time you finally reach <planet>, construction on the outfitter is already underway. The construction workers have laid the foundation of the outfitter close to the spaceport, taking up a good portion of a park.`
			`	"I had to pay a pretty penny to get the outfitter this close to the spaceport," Turner says to you, "but it'll all be worth it in the end.`
			`	"The outfitter should be done in three months or so. You'll know it's done once you find an extra two thousand credits in your pocket every day." Turner pats you on the back. "Have fun until then, Captain <last>. Keep yourself busy saving the galaxy."`

event "outfitter on greenwater"
	planet "Greenwater"
		outfitter "Basic Outfits"
		outfitter "Ammo North"
		outfitter "Ammo South"

mission "Expanding Business: outfitter complete"
	landing
	invisible
	to offer
		has "event: outfitter on greenwater"
	on offer
		"salary: Turner Incorporated" = 2000
		event "request for a shipyard" 270
		fail

event "request for a shipyard"

mission "Expanding Business [5]"
	landing
	name "A New Proposition"
	description "Meet with David Turner on <destination> to talk about a new proposition."
	source
		government "Hai"
	destination "Greenwater"
	to offer
		has "event: request for a shipyard"
	on offer
		dialog `You receive a message from David Turner when you land. "Hello, Captain. I hope you've been enjoying your share in the outfitter. I have a new proposition for you, as I've bought out the rest of the park around the outfitter. Meet me on <destination> if you'd like to hear about it."`

mission "Expanding Business [6]"
	landing
	name "A New Proposition"
	description "Escort the freighters to <destination> in order to pick up the supplies for the shipyard."
	destination "Sunracer"
	to offer
		has "Expanding Business [5]: done"
	on offer
		conversation
			`Turner meets you in a high-end human-owned restaurant in the richer part of the city, very much reminiscent of something you would find on a Paradise Planet. "It's been quite some time since we last spoke, Captain <last>. Over a year now," he says. "Have you been enjoying the extra cash in your pocket every day, Captain <last>?"`
			choice
				`	"Yes. It's been a huge help paying crew salaries."`
					goto salaries
				`	"Two thousand credits each day isn't much for me."`
			
			`	"I suppose two thousand credits every day wouldn't be much to a hero such as yourself. Spaceships are expensive, after all. How does four thousand credits every day sound to you?"`
				goto choice
			
			label salaries
			`	"I'm glad to hear that, Captain <last>. I spent my early years as a captain myself, and I didn't much enjoy having to worry about crew salaries every day. Perhaps doubling that amount will help even more."`
			
			label choice
			choice
				`	"Am I getting a raise?"`
				`	"Is this part of your new proposition?"`
					goto proposition
			
			`	"You could call it that," Turner says after sipping from his glass of wine.`
			
			label proposition
			`	"Building a outfitter selling human goods here on <origin> has had to be the best idea I've ever had, Captain <last>, but recently I thought of an even better idea. You see, most of the humans you see flying around in Hai space are flying decades-old ships. Hai ships are prohibitively expensive for humans. The Aphid is nearly three million credits! This means that demand for ships is extremely high among humans, Captain <last>. Do you see where I'm going with this?"`
			choice
				`	"You need me to help you escort freighters again?"`
				`	"Do you want to build a shipyard selling human ships?"`
			
			`	"Yes, Captain. Right now, the only realistic way that a human born here can get a ship is if they know a captain willing to retire. Even then, prices for a human ship can be more than twice what they are across the wormhole. It's preposterous, Captain <last>!`
			`	"I've already made arrangements with the local Hai government. The rest of the park next to the outfitter is now my property, and I intend to use it to build the shipyard. I've also contacted Megaparsec and bought a license to build their ships and some of the outfits they sell on <planet>. My freighters are at the ready in the spaceport right now. All I need you to do is escort them to <destination> and back, and in six to seven months' time when the shipyard is done, you'll reap the rewards. What do you say, Captain <last>? Do you want to be a hero to millions once again?"`
			choice
				`	"Sure, this sounds like a great idea."`
					goto accept
				`	"I'm not interested in working with you anymore, Turner."`
			
			`	Turner smirks at your response. "Understood, Captain <last>. I'll just save myself two thousand credits a day from now on by rescinding your salary. I'll be seeing myself out now."`
			choice
				`	"Goodbye."`
					decline
				`	"Wait! I changed my mind. I'll help you."`
			
			label accept
			`	"Excellent decision, Captain <last>. I'll meet you outside to send the ships off."`
				accept
			
	on decline
		clear "salary: Turner Incorporated"
	
	npc accompany save
		personality escort
		government "Merchant"
		ship "Star Queen (Hai)" "Chryso Vasilia"
	npc accompany save
		personality escort
		government "Merchant"
		fleet
			names "civilian"
			variant
				"Bulk Freighter (Hai)" 3
	
	npc
		personality staying
		government "Pirate"
		system "Ultima Thule"
		fleet "Small Northern Pirates"
	npc
		personality staying
		government "Pirate"
		system "Rajak"
		fleet "Large Northern Pirates"
	npc
		personality staying
		government "Pirate"
		system destination
		fleet "Large Northern Pirates"
		
	on visit
		dialog `You've reached <planet>, but you've left one of the ships you're supposed to be escorting behind. Wait for Turner's ship and all the Bulk Freighters to arrive before landing.`

	on complete
		dialog `The Bulk Freighters are loaded with supplies without any problem. When one of the spaceport workers asks Turner where the supplies are going, he replies, "These are just to expand a business venture of mine on, uh, Glory."`

mission "Expanding Business [7]"
	landing
	name "A New Proposition"
	description "Escort the freighters back to <destination> to begin construction on the shipyard."
	destination "Greenwater"
	to offer
		has "Expanding Business [6]: done"
	
	npc accompany save
		personality escort
		government "Merchant"
		ship "Star Queen (Hai)" "Chryso Vasilia"
	npc accompany save
		personality escort
		government "Merchant"
		fleet
			names "civilian"
			variant
				"Bulk Freighter (Hai)" 3
	
	npc
		personality staying
		government "Pirate"
		system "Cardax"
		fleet "Small Northern Pirates"
	npc
		personality staying
		government "Pirate"
		system "Rajak"
		fleet "Large Northern Pirates"
		
	on visit
		dialog `You've reached <planet>, but you've left one of the ships you're supposed to be escorting behind. Wait for Turner's ship and all the Bulk Freighters to arrive before landing.`

	on complete
		event "shipyard on greenwater" 180
		conversation
			`	Construction on the shipyard begins almost immediately after the supplies are unloaded from the freighters, starting with the demolition of the rest of the park. A downtrodden-looking crowd gathers to watch the demolition, but Turner assures you that there are plenty of other parks in the city for them to go to.`
			`	"Something big is going to come of this, Captain <last>," Turner says. "Just know that you were all part of it. You'll know the shipyard is done when you find an extra four thousand credits in your pocket each day. Goodbye until then, Captain <last>."`

event "shipyard on greenwater"
	planet "Greenwater"
		shipyard "Basic Ships"
		shipyard "Syndicate Basics"
		shipyard "Megaparsec Basics"
		shipyard "Megaparsec Advanced"
		outfitter "Common Outfits"
		outfitter "Syndicate Advanced"
		outfitter "Lovelace Basics"
	fleet "Small Human Merchants (Hai)"
		add variant 20
			"Sparrow"
		add variant 20
			"Star Barge"
		add variant 20
			"Shuttle"
		add variant 5
			"Freighter"
			"Wasp" 2
		add variant 10
			"Freighter"
			"Shuttle" 2
			"Quicksilver"
		add variant 15
			"Bounder"
			"Wasp" 2
		add variant 5
			"Manta"
		add variant 5
			"Freighter" 2
			"Manta"
	fleet "Large Human Merchants (Hai)"
		add variant 6
			"Freighter (Proton)" 2
			"Quicksilver" 2
		add variant 6
			"Freighter" 4
			"Quicksilver" 2
			"Splinter" 1
		add variant 3
			"Freighter" 4
			"Quicksilver" 2
			"Splinter (Laser)" 1
		add variant 3
			"Freighter" 4
			"Quicksilver" 2
			"Splinter (Proton)" 1

mission "Expanding Business: shipyard complete"
	landing
	invisible
	to offer
		has "event: shipyard on greenwater"
	on offer
		"salary: Turner Incorporated" = 4000
		fail



mission "Hiding in Plain Sight"
	description "Bring Arthur and his Hai friend, Kiru, to <destination> for a gaming convention."
	minor
	source
		government "Hai"
	destination "Vinci"
	passengers 2
	to offer
		random < 30
		has "First Contact: Hai: offered"
	on offer
		conversation
			`While eating in a spaceport cafeteria that serves both Hai and human cuisine, you are approached by a teenage human and Hai. "Hello. Do you know how to get to <destination>?" the Hai asks.`
			choice
				`	"I do. Why do you want to go there?"`
				`	"I don't. You'll have to ask someone else."`
					decline
			`	The human responds, "There's a massive convention on <planet> for a game called 'Boundless Frontiers.' The convention has a huge cosplaying scene, and I think Kiru would fit right in."`
			`	"Arthur and I have <payment> to give you if you bring us to the <planet>," Kiru says. "We can find our own way back to the Hai space, as well."`
			choice
				`	"Alright, I can take you there."`
					accept
				`	"Sorry, you'll have to find someone else to bring you."`
					decline
					
	on visit
		dialog `You look for Arthur and Kiru, but realize that they took a ride on one of your escorts! Better depart and wait for your escorts to arrive in this star system.`
	on complete
		payment 75000
		dialog `Arthur and Kiru pay you <payment> before running off to the convention center. As they run away, you notice that Kiru is drawing a number of eyes from the crowd, but no one seems to suspect that he is an actual alien.`



mission "Hai Honeymoon"
	description "Bring Anaya and Touhar to <destination> for their honeymoon."
	minor
	source "Skyfarm"
	destination "Featherweight"
	passengers 2
	to offer
		random < 60
		has "First Contact: Hai: offered"
	on offer
		conversation
			`You hop around the spaceport of <origin>, trying to adjust to the low gravity of this moon, when you are approached by a toweringly tall human woman and an equally tall Hai male who are clearly having no trouble with <origin>'s gravity.`
			`	"You look like you need help there, Captain," the woman says with a chuckle.`
			choice
				`	"Don't worry. I almost have the hang of it."`
				`	"Maybe a little bit."`
			`	"It's always fun watching captains when they step off the comfort of their ship," the Hai says.`
			`	"At least they're trying, Touhar," the woman says.`
			choice
				`	"Can I help you two with something?"`
				`	"Is there something I can help you with, or are you just going to watch me?"`
			`	"Actually, there is something," the woman says. "My name is Anaya, and this is my husband, Touhar. And you are?"`
			choice
				`	"My name is <first> <last>."`
				`	"Wait, your husband?"`
					goto husband
			
			`	"Very nice to meet you, Captain <last>," Touhar says to you.`
				goto next
			
			label husband
			`	"What, you've never seen an interspecies couple before?" Touhar asks with a hint of sarcasm in his voice.`
			
			label next
			`	"We got married last week, and we were hoping to travel to <destination> for our honeymoon. I know it's risky to bring Touhar into human space, but <planet> is a sparsely inhabited world, and I have a friend who owns a house in the mountains far from anyone who could see him."`
			`	"Said friend will be able to arrange for our return to <origin> as well," Touhar adds. "Will you take us?"`
			choice
				`	"Sure."`
					accept
				`	"Sorry, I can't travel that far from here."`
					decline
					
	on visit
		dialog `You look for Anaya and Touhar, but realize that they took a ride on one of your escorts! Better depart and wait for your escorts to arrive in this star system.`
	on complete
		payment 100000
		dialog `Instead of landing in the spaceport where they can be seen, you drop Anaya and Touhar off as close as you can to where they will be staying. The house is a few kilometers away, but they assure you that they can make it on their own. They pay you <payment> and thank you for bringing them this far.`



mission "Pirate Troubles [0]"
	name "Defend <system>"
	description "A sizable group of pirates has found their way into Hai space and is terrorizing the system. Help the Hai fight back against them."
	source
		near "Waypoint" 2
		government "Hai"
	to offer
		has "First Contact: Unfettered: offered"
		"combat rating" > 1100
		random < 10
	on offer
		conversation
			`The peaceful spaceport is suddenly filled with the harsh sound of sirens. You spot some Hai and a small number of humans running to their ships and speeding quickly into orbit. It appears that the system is under attack, but the Unfettered Hai never reach this far south. A loud speaker begins blaring throughout the spaceport: "Unfettered humans have entered the system in a large fleet and have begun attacking! Requesting all combat-worthy pilots to assist in the defense of our space. These enemies of harmony are not welcome here."`
			branch unfettered
				has "Unfettered: Jump Drive Source: offered"
			`	You find the phrase "unfettered humans" odd, but guess that they may be referring to pirates. The Hai will probably be very gracious if you help, but this could also be an easy way to get yourself killed, especially if a group of pirates is bold enough to attack the Hai.`
				goto choice
			
			label unfettered
			`	Your heart drops at the phrase "unfettered humans," as the last time you heard that was when the Unfettered Hai used that phrase to refer to the Alphas. If it is really the Alphas attacking the Hai, then it is probably a good idea to help.`
			label choice
			choice
				`	(Join the defense fleet.)`
					launch
				`	(Stay here until the fight is over.)`
					decline
	npc
		government "Hai"
		personality staying
		fleet "Large Hai"
	npc
		government "Merchant"
		personality staying
		fleet "Large Human Merchants (Hai)"
	npc evade
		government "Pirate"
		personality staying
		fleet
			names "pirate"
			variant
				"Leviathan" 2
				"Mule" 2
				"Firebird"
				"Headhunter" 3
				"Raven" 3

mission "Pirate Troubles [1]"
	landing
	name "Unfettered Humans"
	description `Track down the leaders of the pirate gang "Scar's Legion" and "persuade" them to stop attacking Hai space, then return to <destination> to tell the Hai.`
	source
		government "Hai"
	destination "Hai-home"
	clearance
	to offer
		has "Pirate Troubles [0]: done"
	on offer
		"reputation: Hai" += 20
		conversation
			`The battle has ended, but the spaceport still seems more hectic than usual. Ships are jumping in from the surrounding systems to help any injured and to repair any damage that may have occurred. After some hours pass and the commotion has died down, a Hai elder approaches you. "We have heard from the humans here that you are considered a seasoned fighter among your people. May you lend your combat prowess to us to resolve this issue?"`
			choice
				`	"I'd be glad to help. What can I do?"`
					goto explain
				`	"What issue?"`
			`	"I understand that you just defended this system from human pirates. That is the issue that needs resolved.`
			label explain
			`	"Human attacks on our systems are very rare, but recently we have experienced an increased number of raids. Not all have been as unsuccessful as this one. We captured a crew member of this most recent attack who was attempting to flee in an escape pod, and he gave us information that a gang that calls themselves 'Scar's Legion' has discovered our territory and is responsible for the recent raids.`
			`	"Unfortunately, he would not tell us where this gang is, or who the leader is, so there is nothing we are able to do about it. Many humans who live peacefully among us told us that you might be capable of assistance, though."`
			choice
				`	"I'll see what I can do."`
					goto yes
				`	"You want me to hunt down Scar's Legion to stop them from attacking you?"`
				`	"Sorry, I'm not interested."`
					decline
			`	"We understand that these humans are likely misguided. We ask that you resolve this peacefully if possible, but the loss of life from these continued attacks is unacceptable."`
			choice
				`	"I'll see what I can do."`
					goto yes
				`	"Sorry, but I'm not interested."`
					decline
			label yes
			`	"Thank you. Please return to <destination> after you have sought to resolve this situation."`
				accept
	on visit
		dialog "You've returned to <planet>, but you haven't yet tracked down Scar's Legion. Perhaps you should ask around the spaceport of pirate planets near the wormhole into Hai space for information."
	to complete
		or
			has "accepted scar's legion tribute"
			has "defeated scar's legion"

mission "Pirate Troubles [1]: Farpoint"
	landing
	invisible
	source "Farpoint"
	to offer
		has "Pirate Troubles [1]: active"
	on offer
		conversation
			`You visit the Navy outpost on <origin> and ask the officers there if they have any information on Scar's Legion. After running a background check on you to make sure you're not up to no good, an officer hands you a copy of a folder containing all the information that the Navy has on the gang. "Nothing in here is classified, so you're free to keep it," the officer says.`
			`	You return to your ships and sift through the files. The leader of the gang is named Scar (to no one's surprise), who use to be an important member of another pirate gang before forming his own. The Navy estimates their numbers to be in the low thousands, mostly responsible for petty crime in the Far North and not a cause of too much trouble, but the files all date back to a number of years ago. Clearly something has changed in the time since these files were last updated if Scar's Legion is now powerful enough to even attempt to attack the Hai.`
				decline

mission "Pirate Troubles [1]: Freedom or Zenith"
	landing
	invisible
	source 
		planet "Freedom" "Zenith"
	to offer
		has "Pirate Troubles [1]: active"
	on offer
		payment -5000
		conversation
			`You wander the <origin> spaceport on the lookout for anyone who might have any information on the whereabouts of Scar's Legion. A self-described fixer promises you information in exchange for payment, but after handing her the few credits that she's asking for, she runs off with her gun in her hands to discourage you from following. Perhaps someone on another nearby pirate planet will have actual information for you.`
				decline

mission "Pirate Troubles [1]: Haven"
	landing
	invisible
	source "Haven"
	to offer
		has "Pirate Troubles [1]: active"
	on offer
		payment -100
		"scar's legion information" ++
		conversation
			`You order a drink from a small rundown bar in the <origin> spaceport and try to make small talk with the bartender to get him open to giving information about Scar's Legion. He seems reluctant at first, but eventually warms up to you. A few other patrons of the bar join in on the conversation. Luckily no one seems mad about you asking about Scar's Legion. One of the patrons makes it clear that Scar's Legion has no friends on this world, "at least not anymore."`
			`	You leave the bar after an hour or two. Once you return to your ship, you write down all the information you can remember. The gang use to operate exclusively out of the Far North until they crossed one of the larger gangs, causing them to flee the region a few years ago. One of the pirates guesses that they fled for the Core.`
			`	Another person mentioned that the leader of the gang use to always talk about making their own base in an uninhabited system where no one would find it. "He always talked about hollowing out an asteroid to use as a hideout. My guess is he was just always high on the ringworld shavings his gang was dealing."`
				decline

mission "Pirate Troubles [1]: Stormhold"
	landing
	invisible
	source "Stormhold"
	to offer
		has "Pirate Troubles [1]: active"
	on offer
		"scar's legion information" ++
		conversation
			`It doesn't take long for you to find someone who knows something about Scar's Legion. You meet someone who says he'll give you information "free of charge."`
			`	"Scar's Legion have been a thorn in my side for months now. Wrecked my ship a while back, and have been causing me trouble ever since. If you're planning on taking them out, then I'll tell you everything you need to know."`
			`	The pirate tells you that he doesn't know where the base of Scar's Legion is, but he mentions that they spend a lot of time in the uninhabited systems of the Far North. "Nothing out there but cold rocks and gas giants, but if they're spending so much time out there then they must have set up a base of some sort on one of those frozen planets."`
				decline

event "scar's hideout"
	system "Danoa"
		object
			sprite star/m4
			period 10
		object
			sprite planet/desert7-b
			distance 168.64
			period 75.3935
		object
			sprite planet/fog0-b
			distance 693.93
			period 629.313
			object
				sprite planet/mercury
				distance 174
				period 15.1961
		object
			sprite planet/gas6
			distance 2069.42
			period 3240.9
			object
				sprite planet/lava1-b
				distance 293
				period 11.3672
			object
				sprite planet/rock0-b
				distance 440
				period 20.9186
			object
				sprite planet/lava2-b
				distance 607
				period 33.895
			object "Scar's Hideout"
				sprite "planet/asteroid base"
				distance 809
				period 52.153

planet "Scar's Hideout"
	attributes uninhabited
	landscape land/loc1
	description "Scar's Hideout is a hollowed out asteroids used by Scar's Legion as their main base of operations. From here they harrass anyone making the journey through the uninhabited systems of the Far North. Recently the gang has discovered the wormhole to Hai space, leading them to start causing trouble for more than just unlucky merchants."
	spaceport "The spaceport of Scar's Hideout is a massive hangar dug into the core of the asteroid, accessible only by a single blast door on the ceiling. Judging by the size of the hangar, you'd guess that about a third of the entire asteroid was hollowed out for the spaceport alone."
	security 0
	government "Scar's Legion"

mission "Pirate Troubles [2]"
	landing
	name "Scar's Legion"
	description "You've pieced together enough information to find out that the Scar's Legion hideout is in one of four systems in the Far North. Search those systems for the gang's hideout and confront them."
	waypoint "Danoa"
	waypoint "Rajak"
	waypoint "Sumar"
	waypoint "Hassaleh"
	to offer
		"scar's legion information" >= 2
	on offer
		event "scar's hideout"
		conversation
			`After having visited various pirate worlds asking about Scar's Legion, you believe that you know where their hideout is.`
			`	You know that the leader of Scar's Legion use to talk about wanting a hollowed out asteroid as a base. You also know that Scar's Legion has recently been very active in the uninhabited systems of the Far North. You conclude that the gang's hideout could is likely an asteroid located in one of a few systems that are in proximity to the wormhole that leads to the Hai. You mark <waypoints> on your map and get ready to confront them.`
				accept
	to complete
		never
	to fail
		has "Pirate Troubles [3]: offered"

government "Scar's Legion"
	swizzle 6
	color .78 0 0
	"player reputation" 10
	"attitude toward"
		"Merchant" -0.01
		"Republic" -0.01
		"Hai" -0.01
	bribe 0
	fine 0
	"hostile hail" "hostile pirate"

government " Scar's Legion "
	"display name" "Scar's Legion"
	swizzle 6
	color .78 0 0
	"player reputation" -1000
	bribe 0
	fine 0
	"hostile hail" "hostile pirate"

event "battle against scar's legion"
	system "Danoa"
		fleet "Human Miners" 1600

event "battle against scar's legion over"
	system "Danoa"
		fleet "Small Northern Merchants" 15000
		fleet "Small Northern Pirates" 5000
		fleet "Large Northern Pirates" 16000
		fleet "Large Republic" 30000
		fleet "Human Miners" 1600

mission "Pirate Troubles [3]"
	landing
	name "Scar's Legion"
	description "Having declined the tribute, the leader of Scar's Legion has challenged you to a fight to the death. Defeat the <npc>, then return to <destination>."
	source "Scar's Hideout"
	destination "Hai-home"
	to offer
		has "event: scar's hideout"
	on offer
		conversation
			`You've located the Scar's Hideout, a massive asteroid in orbit around a gas giant. As you fly over the asteroid's surface, you spot an open blast door. They must be inviting you inside. It surprises you that a gang of pirates would be capable of creating such a base, as the materials and time needed to make something like this are immense.`
			`	Upon entering the blast door, it closes behind you, leaving you in complete dark. Suddenly, floodlights flash on all around your ship. The brightness of the lights prevents you from seeing anyone beyond them, but you suspect that there are a number of weapons pointed at your ship right now.`
			`	"Who are you and what do you want?" a voice booms from a loud speaker. You press a button to activate your ship's external speakers.`
			choice
				`	"I'm <first> <last>, here to negotiate on behalf of the Hai."`
					goto negotiate
				`	"I'm <first> <last>, here to take this gang down."`
			`	The voice laughs. "Well too bad, because you're right in the middle of a hornet's nest. Fire, boys!"`
				goto die
			
			label negotiate
			`	The voice laughs. "Ah, yes. Those squirrels. I take it they've had enough of us plundering their systems. Boys!"`
			`	The floodlights turn off, revealing a large room with what must be hundreds of pirates with guns of various sizes trained on your ship. One wrong move and you're toast. "Please, Captain. Step out of your ship."`
			choice
				`	(Comply with the orders.)`
					goto comply
				`	(Attempt to escape.)`
			`	You activate your ship's engines to escape. The floodlights suddenly reactivate.`
			
			label die
			`	Before you can even react, several dozen lasers and streams of bullets come flying out from behind the floodlights. You attempt to pull your ship up and fly straight through the ceiling before your ship is too damaged to move, but then you spot a number of rockets flying straight at your cockpit. You die instantly as the rockets impact the glass in front of you.`
				die
			
			label comply
			`	You step out of your ship, and a tall man with a scar across his cheek steps forward from the crowd of pirates, presumably the leader of the gang.`
			choice
				`	"The Hai ask that you stop attacking their systems."`
					goto negotiations
				`	"You must be Scar."`
			`	"No. Scar is long dead," the leader says.`
			choice
				`	"Oh, so does that make you Scab?"`
				`	"The Hai ask that you stop attacking their systems."`
					goto negotiations
			`	The leader grimaces. "I'll cut your tongue out if you don't watch your mouth."`
			`	You take a step back. "The Hai ask that you stop attacking their systems," you say, attempting not to get shanked.`
			
			label negotiations
			`	"Perhaps we will stop," the leader says with a smile. "Under one condition. We'd like a one time shipment of various Hai weapons and technology. The shipment should be as big as possible. I've seen the freighters those aliens have. They're massive. Load two or three up with the goods and we'll consider focusing our attention elsewhere."`
			choice
				`	"Okay. I'll meet with the Hai and see what they can provide."`
					goto tribute
				`	"I'm afraid that I can't allow that."`
			`	The crowd of pirates response with a cacophony of jeers and boos. The leader raises his fist in the air, and the crowd falls silent. "Well I'm afraid that just won't do."`
			`	The leader paces back and forth in silence for a moment. "Well if we don't get what we want, then we're just going to need to keep on attacking. Which means that your presence here is pretty useless."`
			`	The leader turns to the crowd. "How about a fight? To the death!" The crowd erupts in cheers. The leader turns back to you. "We fight in this system only. Just you and me. You attempt to run, my men hunt you down. How's that sound?" You attempt to respond, but before you can, the leader pulls his gun and aims it at you. "Run."`
					launch
			
			label tribute
			`	"Excellent!" the pirate says, which is met with cheers from the rest of the pirates in the room. "But make it quick. Wouldn't want to keep us waiting." The blast doors reopen, and you return to your ship to leave immediately.`
				flee
	
	on decline
		set "accepted scar's legion tribute"
	on accept
		event "battle against scar's legion"
	
	npc kill
		government " Scar's Legion "
		personality nemesis
		ship "Leviathan (Hai Weapons)" "Keloid"
		dialog "You've defeated the leader of Scar's Legion. The various spectators to the fight aren't attacking you, but it may only be a matter of time before they decide to turn their guns on you for killing their leader. Better head to <destination> before that happens."
	
	npc
		government "Scar's Legion"
		personality nemesis
		fleet "Small Northern Pirates"
		fleet "Large Northern Pirates" 4
	
	on enter
	on enter
		"reputation: Scar's Legion" = -1000
	
	on visit
		dialog phrase "generic bounty hunting on visit"
		
	on complete
		set "defeated scar's legion"
		event "battle against scar's legion over"

mission "Pirate Troubles [4]"
	landing
	name "Pirate Tribute"
	description "Escort the three Hai freighters carrying Hai weapons and technology to <stopovers>, then escort the freighters back to <destination>."
	source "Hai-home"
	stopover "Scar's Hideout"
	clearance
	to offer
		or
			has "defeated scar's legion"
			has "accepted scar's legion tribute"
	on offer
		"reputation: Hai" += 20
		payment 2500000
		conversation
			`Upon landing on <origin>, the Hai authorities give you <payment> for your assistance in defending their systems and for helping to track down the culprits. You're sent to the council of elders, the elected ruling body of the Hai, to tell them about Scar's Legion. "Please, tell us what has occurred," one of the elders says.`
			branch defeated
				has "defeated scar's legion"
			
			`	"They asked that you load three large freighters with various weapons and technology to give to them. Only then will they stop attacking you."`
			`	"A simple request," the elders says. "Little more than what the Unfettered ask of us. We shall load three Geocoris immediately."`
			`	"Who is to say that they will not use our own weapons against us?" another elder chimes in. "This deal could only hurt us."`
			choice
				`	"There's no guarantee that they will not attack again, but they promised that they would focus elsewhere."`
					goto guarantee
				`	"I could return to them and defeat them if you desire."`
			`	"No," says the elder. "We are not interested in condeming these humans to death if all they ask is for technology."`
			
			label guarantee
			`	"I believe a bigger issue here is how this will impact our human friends beyond the wormhole," an elder says. "If these pirates are not attacking us, then who will they be attacking? Will we not simply become weapons dealers for a far off war?"`
			`	"We will inform the Republic Navy that we are providing these pirates with our technology for our own sake. They have been capable of combating our technology in the past. I am sure that they will be able to handle it now. Please, <first>, escort the freighters to these pirates so that they may leave us alone."`
				accept
			
			label defeated
			`	"I defeated the leader of Scar's Legion. They shouldn't cause any more trouble for you now."`
			`	One of the elders frowns. "Did you kill their leader in cold blood, or was it self defense?"`
			choice
				`	"They asked for a tribute of your weapons and technology, but I refused the offer, so they attacked me."`
					goto refused
				`	"They were not willing to negotiate, and I was forced to defend myself."`
			`	"This is most unfortunate," another elder says. "But I am happy to hear that they will not cause any more loss of life among our people."`
				goto end
			
			label refused
			`	"This is most unfortunate," another elder says. "We would have been willing to provide them the technology they sought if only they had asked nicely in the first place."`
			`	"Better that we eliminate a threat instead of make them stronger through becoming their weapons dealer," the first elder says. "These pirates might have attacked us with out own technology, or worse still, attacked other humans with them, making us complicit in this slaughter."`
			
			label end
			`	The elders thank you for your assistance in this situation and send you on your way.`
				decline
	
	on decline
		"reputation: Hai" += 40
	
	npc save accompany
		government " Hai "
		personality escort
		fleet
			names "hai"
			cargo 10
			variant
				"Geocoris" 3
	
	on stopover
		dialog `You lead the Hai freighters into the blast doors. Despite the massive size of the freighters, they all manage to fit into the asteroid's spaceport with some room to spare, a testament to how much work was put into this base. The pirates of Scar's Legion unload all the Hai technology from the freighters. After the last crate is gone, the freighters quickly launch from the asteroid.`
	
	on visit
		dialog phrase "generic arrived-without-npc dialog"
	
	on complete
		"reputation: Hai" += 40
		payment 500000
		dialog `With the freighters safely returned, the Hai thank you for resolving the situation with Scar's Legion and hand you <payment> for your help.`
